<template>
  <div>
    <h1>{{ title }}</h1>
    <h3 v-for="m in movies" :key="m">
      - {{ m }}
    </h3>
    <hr>
    {{ intro }}
     <hr>
     <input type="button" value="组件传值" @click="sendVal">
  </div>
</template>

<script>
import eventBus from '@/lib/EventBus'
export default {
  /** props就是用来接收父组件传递过来的数据 */
  props: {
    movies: [],
    title: {},
    intro: {
      default: '该作者什么也没有留下'
      // type: Number
    }
  },
  data () {
    return {
      user: { username: '张三', age: 22 }
    }
  },
  methods: {
    sendVal () {
      eventBus.$emit('sendUser', this.user)
    }
  },
  mounted () {
    console.log('left,mounted')
  },
  destroyed () {
    console.log('left destory')
  }
}
</script>
<style scoped>
  h1 {
    color:#f00;
  }
</style>
